package domain;

import statics.Validation;

public class ConcretePerk implements Perk{
	
	private int hp; //Hit points
	private int ap; //Attack points
	private int dr; //Defence rating
	private int sp; //Speed
	private int range; //Range 
	private String name;
	private short canMine;
	private short canBuild;
	private boolean incdec;
	
	
	
	public ConcretePerk(int hp, int ap, int dr, int sp, int range, String name,
			short canMine, short canBuild, boolean incdec) {
		this.hp = hp;
		this.ap = ap;
		this.dr = dr;
		this.sp = sp;
		this.range = range;
		this.name = name;
		this.canMine = canMine;
		this.canBuild = canBuild;
		this.incdec = incdec;	//INC = 1; DEC = 0
	}
	public int getHP(){return Validation.checkValue(hp,incdec);}
	public int getAP(){return Validation.checkValue(ap,incdec);}
	public int getSP(){return Validation.checkValue(sp,incdec);}
	public int getDR(){return Validation.checkValue(dr,incdec);}
	public int getRange(){return Validation.checkValue(range,incdec);}
	public short resources(){return canMine;}
	public short buildings(){return canBuild;}
	
	public String toString(){
		String s = name;
		int abshp = Validation.checkValue(hp, incdec);
		int absap = Validation.checkValue(ap, incdec);
		int abssp = Validation.checkValue(sp, incdec);
		int absdr = Validation.checkValue(dr, incdec);
		int absrange = Validation.checkValue(range, incdec);
		
		if(abshp > 0)
			s += ", increases hp by "+hp;
		else if(abshp < 0)
			s += ", decreases hp by "+hp;
		
		if(absap > 0)
			s += ", increases attack by "+ap;
		else if(absap < 0)
			s += ", decreases attack by "+ap;
		
		if(abssp > 0)
			s += ", increases speed by "+sp;
		else if(abssp < 0)
			s += ", decreases speed by "+sp;
		
		if(absdr > 0)
			s += ", increases defence by "+dr;
		else if(absdr < 0)
			s += ", decreases defence by "+dr;
		
		if(absrange > 0)
			s += ", increases range by "+range;
		else if(absrange < 0)
			s += ", decreases range by "+range;
		
		if(canMine != 0)
			s += ", allows you to mine "+Validation.mineId(canMine);
		
		if(canBuild != 0)
			s += ", allows you to build "+Validation.buildingId(canBuild);
		
		return s;
	}
}
